{% extends 'admin/model/list.html' %}
    {% block model_list_table %}
    <div class="table-responsive">
    <table class="table table-striped table-bordered table-hover model-list">
        <thead>
            <tr>
                {% block list_header scoped %}
                    {% if actions %}
                    <th class="list-checkbox-column">
                        <input type="checkbox" name="rowtoggle" class="action-rowtoggle" title="{{ _gettext('Select all records') }}" />
                    </th>
                    {% endif %}
                    {% block list_row_actions_header %}
                        {% if admin_view.column_display_actions %}
                        <th class="col-md-1">&nbsp;</th>
                        {% endif %}
                    {% endblock %}
                    {% for c, name in list_columns %}
                    {% set column = loop.index0 %}
                    <th class="column-header col-{{c}}">
                        {% if admin_view.is_sortable(c) %}
                            {% if sort_column == column %}
                                <a href="{{ sort_url(column, True) }}" title="{{ _gettext('Sort by %(name)s', name=name) }}">
                                    {{ name }}
                                    {% if sort_desc %}
                                        <span class="fa fa-chevron-up glyphicon glyphicon-chevron-up"></span>
                                    {% else %}
                                        <span class="fa fa-chevron-down glyphicon glyphicon-chevron-down"></span>
                                    {% endif %}
                                </a>
                            {% else %}
                                <a href="{{ sort_url(column) }}" title="{{ _gettext('Sort by %(name)s', name=name) }}">{{ name }}</a>
                            {% endif %}
                        {% else %}
                            {{ name }}
                        {% endif %}
                        {% if admin_view.column_descriptions.get(c) %}
                            <a class="fa fa-question-circle glyphicon glyphicon-question-sign"
                               title="{{ admin_view.column_descriptions[c] }}"
                               href="javascript:void(0)" data-role="tooltip"
                            ></a>
                        {% endif %}
                    </th>
                    {% endfor %}
                {% endblock %}
            </tr>
        </thead>
        {% for row in data %}
        <tr>
            {% block list_row scoped %}
                {% if actions %}
                <td>
                    <input type="checkbox" name="rowid" class="action-checkbox" value="{{ get_pk_value(row) }}" title="{{ _gettext('Select record') }}" />
                </td>
                {% endif %}
                {% block list_row_actions_column scoped %}
                    {% if admin_view.column_display_actions %}
                    <td class="list-buttons-column">
                        {% block list_row_actions scoped %}
                          {% for action in list_row_actions %}
                          {{ action.render_ctx(get_pk_value(row), row) }}
                          {% endfor %}
                        {% endblock %}
                    </td>
                    {%- endif -%}
                {% endblock %}

                {% for c, name in list_columns %}
                    <td class="col-{{c}}">
                    {% if admin_view.is_editable(c) %}
                        {% set form = list_forms[get_pk_value(row)] %}
                        {% if form.csrf_token %}
                        {{ form[c](pk=get_pk_value(row), display_value=get_value(row, c), csrf=form.csrf_token._value()) }}
                        {% elif csrf_token %}
                        {{ form[c](pk=get_pk_value(row), display_value=get_value(row, c), csrf=csrf_token()) }}
                        {% else %}
                        {{ form[c](pk=get_pk_value(row), display_value=get_value(row, c)) }}
                        {% endif %}
                    {% else %}
                        {% if c=='userId' %}
                            <a data-target="#fa_modal_window" title="编辑记录" href="/admin/admin.order/user/?id={{ get_value(row, c) }}&url=%2Fadmin%2Fadmin.order%2F&modal=True" data-toggle="modal" >{{  getUserNameFromId(get_value(row, c))}}</a>
                        {% elif c=='addressId' %}
                           <a data-target="#fa_modal_window" title="编辑记录" href="/admin/admin.order/address/?id={{ get_value(row, c) }}&url=%2Fadmin%2Fadmin.address%2F&modal=True" data-toggle="modal" >{{  getAddressFormId(get_value(row, c))}}</a>
                        {% else %}
                            {{ get_value(row, c) }}


                        {% endif %}


                    {% endif %}
                    </td>
                {% endfor %}
            {% endblock %}
        </tr>
        {% else %}
        <tr>
            <td colspan="999">
                {% block empty_list_message %}
                <div class="text-center">
                    {{ admin_view.get_empty_list_message() }}
                </div>
                {% endblock %}
            </td>
        </tr>
        {% endfor %}
    </table>
    </div>
    {% block list_pager %}
    {% if num_pages is not none %}
    {{ lib.pager(page, num_pages, pager_url) }}
    {% else %}
    {{ lib.simple_pager(page, data|length == page_size, pager_url) }}
    {% endif %}
    {% endblock %}
    {% endblock %}
